package ModelLayer;

import java.util.ArrayList;
/**
 * Write a description of class LoanContainer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class LoanContainer
{
    private ArrayList<Loan> loans;
    private static LoanContainer instance;
    
    public static LoanContainer getSingleton()
    {
        if(instance == null)
        {
            instance = new LoanContainer();
        }
        return instance;
    }
    
    public LoanContainer()
    {
        loans = new ArrayList<Loan>();
    }
    
    public void createLoan(Person loaner, Specimen specimen, int loanId)
    {
        Loan loan = new Loan(loaner, specimen, loanId);
        loans.add(loan);
    }
    
    public void returnLoan(int loanId)
    {
        int index = 0;
        boolean found = false;
        while(index < loans.size())
        {
            if(loans.get(index).getLoanId() == loanId)
            {
                loans.remove(index);
            }
            else
            {
                index++;
            }
        }
    }
}